package ch.uzh.ifi.seal.ssqa.popup.actions;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;

import ch.uzh.ifi.seal.ssqa.storage.IStorage;
import ch.uzh.ifi.seal.ssqa.storage.TeneoHibernateStorage;

public class InitializeDatabaseAction implements IObjectActionDelegate {
	
	/**
	 * Constructor for Action1.
	 */
	public InitializeDatabaseAction() {
		super();
	}

	/**
	 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
	 */
	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
	}

	/**
	 * @see IActionDelegate#run(IAction)
	 */
	public void run(IAction action) {
		IStorage storage = new TeneoHibernateStorage();
		storage.createNewModelDB();
		MessageDialog.open(MessageDialog.INFORMATION, PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Database initialized", "A new empty database has been initialized.", SWT.None);

	}

	/**
	 * @see IActionDelegate#selectionChanged(IAction, ISelection)
	 */
	public void selectionChanged(IAction action, ISelection selection) {
	}

}
